import download from '@/components/common/download'
import {findFileList} from '@/api/api.js'

export default {
    components:{download},
    props:['win'],
    data() {
        return {
            brand:[
                {name:'lang.fun_exp'},
                {name:'cm.details'}
            ],
            dataList:[],
            fileProps:[
                {prop:'fileRealName',label:'文件名'},
                {prop:'createTime',label:'上传时间'},
            ],
            cudBonusProperty:[],
        }
    },
    methods: {
        //关闭弹窗
        closeWindow:function(){
            this.$emit('closeWindows');
        },
        //获取上传文件列表
        getFileList:function(id){
            let _this = this;
            findFileList({winId:id}).then((result) => {
                if(result.status == "200" && result.data.code =="0"){
                    _this.dataList = result.data.data;
                }else{
                    _this.$alert(result.data.msg,_this.$t('cm.tips'));
                }
            }).catch((err) => {
                _this.$alert(err,_this.$t('cm.tips'));
            });
        }
    },
    mounted() {
        this.getFileList(this.win.cudWinId);
        if(this.win.cudBonusProperty == null){
            this.cudBonusProperty = [];
        }else{
            this.cudBonusProperty = this.win.cudBonusProperty.split(',');
        }
    },
    computed: {
        cudWinId(){
            return this.win.cudWinId;
        }
    },
    watch: {
        cudWinId(newV,oldV){
            this.getFileList(newV);
        },
        win:function(newv,oldv){
            if(newv.cudBonusProperty == null){
                this.cudBonusProperty = [];
            }else{
                this.cudBonusProperty = this.win.cudBonusProperty.split(',');
            }
        }
    },

}